package com.web.service;

import com.web.dao.ExpertsMapper;
import com.web.dao.UserDataMapper;
import com.web.dao.UserExpertMapper;
import com.web.entity.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class ExpertsService {
    @Resource
    private ExpertsMapper expertsMapper;
    @Resource
    private UserExpertMapper userExpertMapper;
    @Resource
    private UserDataMapper dataMapper;
    /**
     * 查询所有专家
     * @return
     */
    public List<ExpertsList> getExpertsList(String userId) {
        return expertsMapper.getExpertsList(userId);
    }

    /**
     * 关注专家
     * @param concernedExperts
     */
    public void insertConcernedExperts(ConcernedExperts concernedExperts) {
        expertsMapper.insertConcernedExperts(concernedExperts);
    }

    /**
     * 查询是否有关注过该专家
     * @return
     */
    public ConcernedExperts findMyConcernedExperts(String user_id,String touser_id,Integer type){
        return expertsMapper.findMyConcernedExperts(user_id,touser_id,type);
    }

    /**
     * 我的关注列表
     * @param userid
     * @return
     */
    public List<MyExperts> getMyConcern(String userid) {
        return expertsMapper.getMyConcern(userid);
    }

    /**
     * 取消关注

     */
    public void RemoveConcerns(String user_id,String touser_id,Integer type) {
        expertsMapper.RemoveConcerns(user_id,touser_id,type);
    }

    /**
     * 专家详情
     * @param id
     * @return
     */
    public ExpertsDetails getExpertsDetails(Integer id) {
        return expertsMapper.getExpertsDetails(id);
    }

    /**
     * 专家项目经验
     * @param user_id
     * @return
     */
    public List<Case> getProjectExperience(String user_id) {
        return  expertsMapper.getProjectExperience(user_id);
    }

    /**
     * 专家历史发布
     * @param id
     * @return
     */
    public List<ExpertRelease> HistoricalRelease(Integer id) {
        return expertsMapper.HistoricalRelease(id);
    }

    /**
     * 专家项目案例表
     * @param id
     * @return
     */
    public List<Case> ClassicCase(Integer id) {
        return expertsMapper.ClassicCase(id);
    }

    /**
     * 获取热门专家
     * @param userId
     * @return
     */
    public List<HotExpertBean> getHotExpert(String userId){
        return userExpertMapper.getHotExpert(userId);
    }

    /**
     * 获取热门视频
     * @return
     */
    public List<HotUserData> getHotUserVideos(){
        return dataMapper.getHotVideos();
    }

    /**
     * 获取热门资料
     * @return
     */
    public List<HotUserTextBean> getHotUserText(){
        return dataMapper.getHotText();
    }

    /**
     * 获取技能-问答不带照片和视频
     * @return
     */
    public List<UserQuestion> getUserQuestion() {
        return expertsMapper.getUserQuestion();
    }
    /**
     * 获取技能-问答带照片和视频
     * @return
     */
    public List<UserAnswer> getUserAnswer() {
        return expertsMapper.getUserAnswer();
    }


    /**
     * 根据条件查询问答相关字段
     * @param key
     * @param value
     * @return
     */
    public UserAnswer selectById(String key,String value) {
        UserAnswer userAnswer=expertsMapper.selectById(key,value);
        userAnswer.setSee_num(userAnswer.getSee_num()+1);
        expertsMapper.updateUserQuiz(userAnswer);
        return userAnswer;
    }
}
